<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,userscalableb=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        (function () {
            var html = document.documentElement;
            var hWidth = html.getBoundingClientRect().width;
            html.style.fontSize = hWidth / 16 + "px";
        })();
    </script>
    <style>
        body {
            margin: 0;
        }

        div {
            float: left;
            width: 4rem;
            height: 4rem;
            border: 1px solid #000;
            box-sizing: border-box;
        }

        div:nth-of-type(1) {
            background: red;
        }

        div:nth-of-type(2) {
            background: yellow;
        }

        div:nth-of-type(3) {
            background: green;
        }

        div:nth-of-type(4) {
            background: pink;
        }
    </style>
</head>

<body>
    <!--
        rem/em
        rem根据跟节点的大小进行设置
    -->
    <div></div>
    <div></div>
    <div></div>
    <div></div>
</body>

</html>